package edu.hawaii.ics466.tasks;

import java.util.HashMap;
import java.util.Map;

import edu.hawaii.ics466.objects.GameInfo;

import android.os.AsyncTask;
import android.util.Log;

public class GetGameInfo extends AsyncTask<String, Void, GameInfo> {

	@Override
	protected GameInfo doInBackground(String... params) {
		String gameName = (params.length > 0) ? params[0] : "";

		Map<String, String> requestParams = new HashMap<String, String>();
		requestParams.put("gameName", gameName);
		String response = Ajax.send("http://the-game-rater.comuf.com/app/get_game_info.php", requestParams);
		if(response != null) {
			String[] info = response.split(";");
			if(info.length >= 4) {
				return new GameInfo(info[0], info[1], info[2], info[3]);
			}
		}
		return null;
	}
}
